"""
将十进制转换为任意进制的数(不大于十六进制)
"""
from data_structure.stack.stacks import Stack


class Solution:

    @staticmethod
    def convert(decimal_num, base):
        digits = "0123456789ABCDEF"

        stack = Stack()

        if base <= 1 or not isinstance(base, int):
            print("请输入大于1的整数")
            return

        while decimal_num > 0:
            stack.push(decimal_num % base)
            decimal_num = decimal_num // base

        res_str = ""
        while not stack.is_empty():
            res_str += str(digits[stack.pop()])
        return res_str if res_str else "0"
